<?php

$inSession = isset($_SESSION["me"]);
$loginFailed = false;

if(!isset($hideLogin)){
	$hideLogin = false;
}
$relPath = (strpos($_SERVER["REQUEST_URI"],"/admin/")> -1)?"../":"";
?>
<script type="text/javascript">
	$(document).ready(function(){
		$("#formLogin").submit(function(){
			if($("#emailaddress").val() != "" && $("#password").val() != ""){
				return true;
			}
			alert("Something missing here..");
			return false;
		});		
	});
</script>
<form id="formLogin" name="formLogin" action="index.php" method="POST">
<div id="topsection">
	<div class="innertube" style="text-align:right;">
	<?php if(!$inSession){
		if(!$hideLogin){
			
			if(isset($_GET["loginfailed"]) && $_GET["loginfailed"] == "true"){?><font color="red">Login failed!&nbsp;</font><?php }?>
			Email:<input type="text" id="emailaddress" name="emailaddress" value="" />
			Password: <input type="password" id="password" name="password"/>
			<input type="submit" name="btnLogin" value="Go!"/>
			
			<br/>
			<a href="reset_password.php">forgot password?</a>
		<?php }
		}else{
		$currentUser = new Player();
		if(isset($_SESSION["me"])){
			$currentUser = $_SESSION["me"];
		}
		
		echo "Hi ".$currentUser->firstName." ".$currentUser->lastName;
		printf("&nbsp;<a href=\"?viewProfile&playerid=%d\">Profile</a>",$_SESSION["me"]->playerid);
		if($_SESSION["me"]->admin)
			printf("&nbsp;<a href=\"?%s\">Admin</a>",AdminItemEnum::PLAYER_MGMT);
		
	 }?>
		<a href="?logout">Logout</a>
	</div>
	<div class="innertube" style="text-align:center;">
		<h1 style="padding-top:0px">Walter J Corbette</h1>
	</div>
</div>
</form>